package cn.liontalk.producter;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author: 周哲
 * @package: cn.liontalk.producter
 * @description:
 * @date: 2019/1/10 19:33
 * @version: V1.0
 */
@Component
public class UserSender {


    @Autowired
    private AmqpTemplate template;

    @Value("${mq.config.exchange}")
    private String exchange;


    public void send(String message) throws IOException, TimeoutException {
        template.convertAndSend(exchange, "user.log.debug", message);
        template.convertAndSend(exchange, "user.log.info", message);
        template.convertAndSend(exchange, "user.log.error", message);
        template.convertAndSend(exchange, "user.log.warn", message);
    }
}
